package main

import (
	"crypto/sha256"
	"fmt"
)

func main() {
	hashcode := sha256.Sum256([]byte("x"))

	var pc [256]byte = func() (pc [256]byte) {
		for i := range pc {
			pc[i] = pc[i/2] + byte(i&1)
		}
		return
	}()

	ret := 0
	i := len(hashcode)

	for i > 0 {
		b := i - 1
		//字节切片
		newstr := hashcode[b:i]
		// fmt.Printf("%d\t%x\n", len(newstr), newstr[0])
		//十六进制也能转？
		ret += int(pc[newstr[0]])
		i = b
	}
	fmt.Println(ret)
}
